package com.ysd.controller;



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ysd.entity.Administratorss;
import com.ysd.repository.AdministratorssRepository;
import com.ysd.utils.Result;

@RestController
public class AdminintratorssController {
	@Autowired
	AdministratorssRepository adminRepository;
	@RequestMapping("/login1")
	public Object login1(String name,String password,HttpServletRequest request) {
		Administratorss admin=adminRepository.findByNameAndPassword(name, password);
		if (admin!=null) {
			 HttpSession session=request.getSession();
			 session.setAttribute("login","name");
			return Result.toClient("0", "登录成功", admin);
		} else {
			return Result.toClient("1", "登录失败", null);
		}
	}
}
